/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package my.cbr.utils;

import java.util.Random;

/**
 * @deprecated 
 * @author Marte
 */
public class ValueEvaluator {

    private Double[] testValues;
    private Double minThreshold = 0d;
    private Double maxThreshold = 0d;


    public ValueEvaluator()
    {
        testValues = new Double[101];
        populate();

        double meanVal = this.getMean();

        this.printList();

        System.out.println("The mean: "+meanVal);

        this.findThresholds();

    }

    public ValueEvaluator(Double[] inputVal)
    {
        testValues = inputVal;

        double meanVal = this.getMean();

        this.printList();

        System.out.println("The mean: "+meanVal);

        this.findThresholds();
    }

   public Double getMaxThreshold() {
        return maxThreshold;
    }

   public Double getMinThreshold() {
        return minThreshold;
    }

    private void populate()
    {
        for (int i = 0; i < testValues.length; i++)
        {
            //double r = new Random().nextDouble();
            testValues[i] = (double)i;
        }
    }

    private void printList()
    {
        for (int i = 0; i < testValues.length; i++)
        {
            System.out.println(testValues[i]);

        }
    }

   public void findThresholds()
    {
        Double max = testValues[testValues.length-1];
        minThreshold = max * (1/3.0);
        maxThreshold = max * (2/3.0);

        System.out.println("Min val: "+minThreshold);
        System.out.println("Max val: "+maxThreshold);

        int j = 0;

        for (int i = 0; i < testValues.length; i++)
        {
            if(testValues[i] >= minThreshold)
            {
                System.out.println("minThreshold: "+testValues[i]);
                j = i;
                break;
            }
           
        }

        for (int i = j; i < testValues.length; i++)
        {
            if(testValues[i] >= maxThreshold)
            {
                System.out.println("maxThreshold: "+testValues[i]);
                break;
            }
        }
    }
    public Double getMean()
    {
        Double mean = 0.0;
        Double all = 0.0;

        for (int i = 0; i < testValues.length; i++)
        {
            all += testValues[i];

        }

        mean = all/testValues.length;

        return mean;
    }

    public static void main(String[] args)
    {
        Double[] dob = new Double[5];
        dob[0] = 1.0;
        dob[1] = 4.0;
        dob[2] = 5.5;
        dob[3] = 70.0;
        dob [4] = 80.5;

        ValueEvaluator val = new ValueEvaluator(dob);
        

    }

}
